import pandas as pd
person_message = pd.read_excel('accountMessage.xlsx')
person_message.fillna(person_message['Age'].mean(),inplace=True)

age_maxf = person_message['Age'].value_counts().index[0]
person_message['Age'].fillna(age_maxf,inplace=True)
# 体重转换
rows_with_lbs = person_message['Weight'].str.contains('lbs').fillna(False)
print(rows_with_lbs)
for i,lbs_row in person_message[rows_with_lbs].iterrows():
     # print(i)
     # print('---------')
     # print(lbs_row)
     weight = int(float(lbs_row['Weight'][:-3])/2.2)
     person_message.at[i,'Weight'] = '{}kgs'.format(weight)
person_message[['first_name','last_name']] = person_message['Name'].str.split(expand=True)
# 删除非 ASCII 字符
person_message['first_name'].replace({r'[^\x00-\x7F]+':''}, regex=True, inplace=True)
person_message['last_name'].replace({r'[^\x00-\x7F]+':''}, regex=True, inplace=True)
person_message.drop_duplicates('Name',inplace=True)
person_message.to_excel('personMessage.xlsx')
# print(person_message['first_name'])